define(function (require,exports,module) {
    var angular = require('angular');

    var material = angular.module('material.videoService',[]);

    material.factory('videoService',[
        'http',
        function (http) {
            return {
                getVideoList: function (options) {
                    http.get('material/video-list',options.search)
                        .success(function (res) {
                            if (res.retCode == 0) {
                                return options.success(res);
                            }
                            options.fail && options.fail(res);
                        })
                        .error(function (res) {
                            options.fail && options.fail(res);
                        });
                },
                createVideo: function (options) {
                    http.post('material/save',options.data,options.search)
                        .success(function (res) {
                            if (res.retCode == 0) {
                                return options.success(res);
                            }
                            options.fail && options.fail(res);
                        })
                        .error(function (res) {
                            options.fail && options.fail(res);
                        });
                },
                deleteVideo: function (options) {
                    http.get('material/del-video',options.search)
                        .success(function (res) {
                            if (res.retCode == 0 || res.result) {
                                return options.success(res);
                            }
                            options.fail && options.fail(res);
                        })
                        .error(function (res) {
                            options.fail && options.fail(res);
                        });
                },
                queryVideoInfo: function (options) {
                    http.get('material/get-video',options.search)
                        .success(function (res) {
                            if (res.retCode == 0 || res.result) {
                                return options.success(res);
                            }
                            options.fail && options.fail(res);
                        })
                        .error(function (res) {
                            options.fail && options.fail(res);
                        });
                }
            };
        }
    ]);
});
